from multiprocessing import Pool
import time

def subworker(msg):
    print "Subprocess:", msg
    time.sleep(3)
    print "End process", msg
    return "done " + str(msg)

if __name__ == "__main__":
    pool = Pool(processes=4)
    print "This is the main process!"
    for i in xrange(3):
        ret = pool.apply_async(subworker, (i, ))
        print ret.get()
    pool.close()
    pool.join()
    print "Sub-process(es) done."
